﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Camelot.SharePointIntegration.Client;

namespace Examples
{
    class Program
    {
        static void Main(string[] args)
        {
            const string connectionString = @"Server=yoursharepointserver;Database=;Domain=;User=spuser;Password=sppassword;Authentication=Ntlm;TimeOut=50;RecursiveMode=RecursiveAll;DecodeName=True;NoListFilters=True;ExpandUserFields=True;StrictMode=True;DefaultLimit=10000;ServerUrlRelativeList=True;MaxReceivedMessageSize=10000000";
            const string listName = "Tasks";
            const string viewName = "All Tasks";
            const string sqlQuery = @"select id, title, Status from tasks";
            const string xmlFile = @"c:\tasks.xml";
            const string cmpFile = @"c:\tasks.cmp";
            const string csvFile = @"c:\tasks.csv";
            const string sqlFile = @"c:\tasks.sql";
            const string xmlFileDocumentLibrary = @"c:\documents.xml";

            //PrintDocumentLibraryHierarchy.DoIt(connectionString);
            //PrintDocumentLibraryUrls.DoIt(connectionString);
            //DownloadDocumentLibraryHierarchy.DoIt(connectionString, @"c:\sharepoint_files\");
            //ExportDocumentLibraryAsCamelotXml.DoIt(connectionString, xmlFileDocumentLibrary);
            //ReadCamelotXmlToDocumentLibraryData.DoIt(xmlFileDocumentLibrary);
            
            //ExportListAsCamelotXml.DoIt(connectionString, listName, viewName, xmlFile);
            //ExportListAsCamelotXmlCompressed.DoIt(connectionString, listName, viewName, cmpFile);
            //ExportListAsCamelotXmlUsingCData.DoIt(connectionString, listName, viewName, xmlFile);
            //ExportQueryAsCamelotXml.DoIt(connectionString, sqlQuery, xmlFile);
            
            //ReadCamelotXmlToListData.DoIt(xmlFile);
            //ReadCamelotXmlCompressedToListData.DoIt(cmpFile);
            //ReadCamelotXmlUsingXmlDocument.DoIt(xmlFile);

            //ExportListAsCsvFile.DoIt(connectionString, listName, viewName, csvFile);
            //ExportListAsMySqlDump.DoIt(connectionString, listName, viewName, sqlFile);
            //ExportListAsMySqlDump.DoIt(connectionString, listName, viewName, sqlFile);

            /*
             * for this section, modify the endpoint address in app.config
             * default: endpoint address="http://yoursharepointserver:8080/"
             */

            /*
             * modify username, password and domain, also modify the "shared key" so that it matches the WcfService
             */

            //WcfServiceUsingNtlmAuthentication.DoIt("username", "password", "domain");
            //WcfServiceExecuteQueryToListData.DoIt("sharepoint_default", "MySharedKey".MD5(), sqlQuery, "username", "password", "domain");

            Console.ReadKey();
        }
    }
}
